package com.yangming.springboot.deepin.playTest;

import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;

/**
 * @创建人 ym
 * @创建时间 2021/4/22 0022
 * @描述
 **/
public class AtomicIntegerFieldUpdaterTest {

    private static AtomicIntegerFieldUpdater<User> a = AtomicIntegerFieldUpdater.newUpdater(User.class, "old");

    public static void main(String[] args){
        User conan = new User("conan", 10);
        System.out.println(a.getAndIncrement(conan));
        System.out.println(a.get(conan));
    }

    public static class User{
        private String name;
        public volatile int old;
        public User(String name, int old){
            this.name = name;
            this.old = old;
        }
        public String getName(){return this.name;}
        public int getOld(){return this.old;}
    }

}
